package com.wangjw.rest;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * Created by wangjw on 18/6/28.
 */
public class JAXRS20Client {

    public static void main(String[] args) {
        String baseAddress = "http://localhost:8080/ws/rest";

        JacksonJsonProvider jsonProvider = new JacksonJsonProvider();
        List productList = ClientBuilder.newClient()
                .register(jsonProvider)
                .target(baseAddress)
                .path("/products")
                .request(MediaType.APPLICATION_JSON)
                .get(List.class);

        for (Object product : productList) {
            System.out.println(product);
        }
    }
}
